/*
 * @Author: zxh
 * @Email: 1271027008@qq.com
 * @Date: 2020-02-24 08:53:29
 * @Descripttion: 多发/多收
 */
import { Injectable } from '@angular/core';
import { SubwarehouseManageService } from '../../basedata-manage/subwarehouse-manage/subwarehouse-manage.service';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, Observer, from } from "rxjs";
import { SubmaterialManageService } from '../../basedata-manage/submaterial-manage/submaterial-manage.service'
import { MaterialRelationService } from '../../basedata-manage/material-relation/material-relation.service'
import { AccountaliasManageService } from '../../basedata-manage/accountalias-manage/accountalias-manage.service'
import { WorkManageService } from '../../basedata-manage/work-manage/work-manage.service'

@Injectable({
  providedIn: 'root'
})
export class ManysendreciveListService {

  constructor(
    private SubwarehouseManageService:SubwarehouseManageService,
    private SubmaterialManageService:SubmaterialManageService,
    private MaterialRelationService:MaterialRelationService,
    private http:HttpClient,
    private AccountaliasManageService:AccountaliasManageService,
    private WorkManageService:WorkManageService
  ) { }
  
  private recordListUrl = '/api/adjustAmount'
  private inOutRecordUrl = '/api/inoutLog'
  private erpUrl = '/api/adjustAmount/confirm'

  // 获取全部库房
  getAllKF(): Observable<any>{
    return this.SubwarehouseManageService.getKFAllList().pipe()
  }
  // 获取全部物料
  getAllWl(): Observable<any>{
    let _data = {}
    return this.SubmaterialManageService.getAllMaterial(_data).pipe()
  }
  // 根据库房库区获取物料
  getMaterialCode(data){
    return this.MaterialRelationService.getAll(data).pipe()
  }

  // 获取列表
  getRecordList(data): Observable<any>{
    let _dataJson = {
      ...data
    }
    console.log(_dataJson)
    return this.http.get(this.recordListUrl,{params:_dataJson}).pipe()
  }

  // 获取出入库记录列表
  getInOutList(data): Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.get(this.inOutRecordUrl,{params:_dataJson}).pipe()
  }

  // 新增多发/多收调整
  addMany(data):Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.post(this.recordListUrl,_dataJson).pipe()
  }
  // 修改多发/多收调整
  editMany(data): Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.put(this.recordListUrl,_dataJson).pipe()
  }
  // 删除多发/多收调整
  delMany(data): Observable<any>{
    let options = {
      headers: {
        "Content-Type": "application/json"
      },
      body: data
    }
    return this.http.delete(this.recordListUrl,options).pipe()
  }
  // 触发ERP
  goREP(data):Observable<any>{
    return this.http.post(this.erpUrl,data).pipe()
  }

  // 获取账户别名
  getZHBM():Observable<any>{
    let _data = {}
    return this.AccountaliasManageService.getAccountalias(_data).pipe()
  }

  // 获取工作令
  getGZL():Observable<any>{
    let _data = {
      pageSize:999,
      page:1
    }
    return this.WorkManageService.apiList(_data).pipe()
  }
  
}